package com.test;
public class ThreadPrint {
    public static void main(String[] args){
        Thread ta = new Thread(() -> {
            for(int i = 1; i <= 100; i++) {
                if(i == 50) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println("线程2打印：a");
            }
        });
        ta.setPriority(Thread.NORM_PRIORITY);
        Thread tb = new Thread(() -> {
            for(int i = 1; i <= 100; i++) {
                if(i == 50) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                System.out.println("线程3打印：b");
            }
        });
        tb.setPriority(Thread.MIN_PRIORITY);
        Thread t1 = new Thread(() -> {
            try {
                tb.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            for(int i = 1; i <= 100; i++) {
                System.out.println("线程1打印：" + i);
            }
        });
        t1.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        ta.start();
        tb.start();
    }
}
